﻿<sap:ActivityDesigner x:Class="Vision.Core.ActivityComponents.IO.File.DirectoryListDesigner"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="clr-namespace:System;assembly=mscorlib"
    xmlns:sa="clr-namespace:System.Activities;assembly=System.Activities"
    xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"
    xmlns:sapc="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation"
    xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation"
    xmlns:converters="clr-namespace:Vision.Core.ActivityComponents.Converters"
    Collapsible="True" ExpandState="True">
    <sap:ActivityDesigner.Resources>
        <ResourceDictionary>
            <sapc:ArgumentToExpressionConverter x:Key="argumentToExpressionConverter" />
            <converters:InArgumentBoolConverter x:Key="argumentBoolConverter" />
            
            <DataTemplate x:Key="ExpandedActivityViewTemplate">
                <StackPanel>
                    <!-- Inputs Header -->
                    <TextBlock Text="Input(s):" FontWeight="Bold" Foreground="Navy" Margin="0,0,0,3" />

                    <Grid Margin="0,5,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="100" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <!-- ModelItem.DirectoryPath -->
                        <TextBlock Grid.Row="1" Grid.Column="0" Text="Directory path:" VerticalAlignment="Top" />
                        <sapv:ExpressionTextBox Grid.Row="1" Grid.Column="1"
                                MaxLines="1" Margin="7,0,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Top"
                                Expression="{Binding Path=ModelItem.DirectoryPath, Mode=TwoWay, Converter={StaticResource argumentToExpressionConverter}, ConverterParameter=In}"
                                ExpressionType="{Binding Path=ModelItem.DirectoryPath.ArgumentType}"
                                OwnerActivity="{Binding Path=ModelItem, Mode=OneWay}" />
                    </Grid>

                    <Grid Margin="0,5,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="100" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <!-- ModelItem.SearchPattern -->
                        <TextBlock Grid.Row="1" Grid.Column="0" Text="Search pattern:" VerticalAlignment="Top" />
                        <sapv:ExpressionTextBox Grid.Row="1" Grid.Column="1"
                                MaxLines="1" Margin="7,0,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Top"
                                Expression="{Binding Path=ModelItem.SearchPattern, Mode=TwoWay, Converter={StaticResource argumentToExpressionConverter}, ConverterParameter=In}"
                                ExpressionType="{Binding Path=ModelItem.SearchPattern.ArgumentType}"
                                OwnerActivity="{Binding Path=ModelItem, Mode=OneWay}" />
                    </Grid>

                    <Grid Margin="0,5,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="100" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <!-- ModelItem.IncludeSubDirectories -->
                        <TextBlock Grid.Column="0" Text="Sub Directories:" VerticalAlignment="Top" />
                        <CheckBox Grid.Column="1" Margin="7,0,0,0"  IsChecked="{Binding Path=ModelItem.IncludeSubDirectories, Mode=TwoWay, Converter={StaticResource argumentBoolConverter}}" />
                    </Grid>

                    <!-- Outputs Header -->
                    <TextBlock Text="Output(s):" FontWeight="Bold" Foreground="Navy" Margin="0,10,0,3" />
                    
                    <Grid Margin="0,5,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="100" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <!-- ModelItem.Directories -->
                        <TextBlock Grid.Row="1" Grid.Column="0" Text="Directories:" VerticalAlignment="Top" />
                        <sapv:ExpressionTextBox Grid.Column="1" MaxLines="1" Margin="7,0,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Top"
                                Expression="{Binding Path=ModelItem.Directories, Mode=TwoWay, Converter={StaticResource argumentToExpressionConverter}, ConverterParameter=Out}"
                                ExpressionType="{Binding Path=ModelItem.Directories.ArgumentType}"
                                OwnerActivity="{Binding Path=ModelItem, Mode=OneWay}"
                                UseLocationExpression="True" />
                    </Grid>

                    <Border BorderThickness="0,0,0,3" Margin="0,5">
                        <Border.BorderBrush>
                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                <GradientStop Color="DarkGray" Offset="0" />
                                <GradientStop Color="White" Offset="1" />
                            </LinearGradientBrush>
                        </Border.BorderBrush>
                    </Border>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="100" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Row="0" Text="Directory array:" VerticalAlignment="Top" Foreground="Gray" />
                        <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Path=ModelItem.Body.Argument.Name, Mode=TwoWay}" Margin="7,0,0,0" Foreground="Gray" />
                    </Grid>
                    <!-- Body -->
                    <sap:WorkflowItemPresenter AutomationProperties.AutomationId="Activity" IsDefaultContainer="True" HintText="Drop activity here" Item="{Binding Path=ModelItem.Body.Handler, Mode=TwoWay}" AllowedItemType="{x:Type sa:Activity}" MinWidth="100" MinHeight="100" Margin="0,7,0,0"/>
                </StackPanel>
            </DataTemplate>
            <DataTemplate x:Uid="DataTemplate_2" x:Key="CollapsedActivityViewTemplate">
                <Label x:Uid="TextBlock_6" Padding="0,0,0,0" FontStyle="Italic" Foreground="{x:Static SystemColors.GrayTextBrush}" HorizontalAlignment="Center" VerticalAlignment="Center">Double-click to view</Label>
            </DataTemplate>
            <Style x:Uid="Style_1" x:Key="FileOpenStyle" TargetType="{x:Type ContentPresenter}">
                <Setter x:Uid="Setter_1" Property="ContentTemplate" Value="{DynamicResource ExpandedActivityViewTemplate}" />
                <Style.Triggers>
                    <DataTrigger x:Uid="DataTrigger_1" Binding="{Binding Path=ShowExpanded}" Value="false">
                        <Setter x:Uid="Setter_2" Property="ContentTemplate" Value="{DynamicResource CollapsedActivityViewTemplate}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </ResourceDictionary>
    </sap:ActivityDesigner.Resources>
    <ContentPresenter x:Uid="ContentPresenter_1" Style="{DynamicResource FileOpenStyle}" Content="{Binding}" />
</sap:ActivityDesigner>
